<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <div id="app">
    <h1>表单绑定值</h1>
    <p>
      把v-model加在会变的值上面，例如：input、select。
      当用户选择了值之后，v-model对应的变量会自动收集那些值。
      只关注这个变量即可，不用操作DOM。
    </p>
    <p>单选</p>
    <label>频道1：</label>
    <input type="radio" v-model="radioCheck" :value="radioVal1">
    <label>频道2：</label>
    <input type="radio" v-model="radioCheck" :value="radioVal2">
    <label>频道3：</label>
    <input type="radio" v-model="radioCheck" :value="radioVal3">
    <br>
    <span>{{radioCheck}}</span>
    <hr>
    <p>多选</p>
    <label>唱:</label>
    <input type="checkbox" v-model="checkboxCheck" 
      :true-value="checkboxVal1" :false-value="checkboxVal101">
    <br>
    <span>{{checkboxCheck}}</span>
    <hr>
    <p>下拉选择器</p>
    <label>收货地址：</label>
    <select v-model="selectCheck">
      <option v-for="(city,index) in selectArr" :key="index" 
      :value="city.value">{{city.text}}</option>
    </select><br>
    <span>val: {{selectCheck.val}}</span>
    <span>code: {{selectCheck.code}}</span>
    <hr>
    <hr>
    <h1>v-model的修饰符</h1>
    <p>.lazy</p>
    <input type="text" v-model.lazy="info1">
    <p>{{info1}}</p>
    <hr>
    <p>.number</p>
    <input type="text" v-model.number="info2">
    <p>{{info2}}</p>
    <hr>
    <p>.trim</p>
    <input type="text" v-model.trim="info3">
    <p>{{info3}}</p>
  </div>
  <script src="../js/vue.js"></script>
  <script>
    let vm = new Vue({
      el: '#app',
      data: {
        radioVal1: 'FM 1041',
        radioVal2: 'FM 881',
        radioVal3: 'FM 75.2',
        radioCheck: 'FM 1041',
        // 
        checkboxVal1: 'sing',
        checkboxVal101: 'singing',
        checkboxCheck: 'sing',
        // 
        selectArr: [
          {
            text: '京',
            value: {
              val: '京',
              code: '1'
            }
          },
          {
            text: '津',
            value: {
              val: '津',
              code: '2'
            }
          },
          {
            text: '沪',
            value: {
              val: '沪',
              code: '3'
            }
          },
          {
            text: '渝',
            value: {
              val: '渝',
              code: '4'
            }
          }
        ],
        selectCheck: '',
        info1: '',
        info2: '',
        info3: ''
      }
    })
  </script>
</body>
</html>